﻿myApp.controller('PropertyNewDetailController', function ($scope, $http, $routeParams,$filter,NgMap) {
  
    //$scope.share = {};




    pageInit();
    function pageInit() {
        var url = 'api/PropertyNew/GetPropertyNew/' + $routeParams.id;
       // alert("Running...");
        $http.get(url).success(function (data) {
            console.log('Property New: ' + JSON.stringify(data));
            $scope.Project = data.PropertyNew;
            $scope.slides = data.pictureList;
        //    $scope.share.url = 'http://www.penangrealty.my/PropertyNewDetail/' + $routeParams.id.toString();
        //    $scope.share.pictureUrl = $scope.slides ? $scope.slides[0].pictureURL : 'http://www.penangrealty.my/images/penang realty,Apartment,house,condominium,terrace house,semi d,detached,bungalow,high end luxury properties,landed properties,gated guarded house.png';
        //    $scope.share.title = '[New Property] ' + $scope.Project.ProjectName + " " + $scope.Project.ProjectLocation
        //    document.title = "Penang Realty 世界地產 " + $scope.share.Title;
        //    $scope.share.description = "Price : " + $scope.Project.ProjectPrice.toLocaleString() + ". " + $scope.Project.ProjectDetails
        //    $scope.$emit('newPageLoaded', { 'title': $scope.share.title, 'description': $scope.share.description });
        })
    }

    $scope.submitForm = function (obj) {
        var url = 'https://script.google.com/macros/s/AKfycbwcomu5o2CIbkO1lCjyZhDrF_dejSPWi0VAj9knYKYRr3jHDUY/exec';
        $http({
            method: 'POST',
            url: url,
            data: $(obj.target).serialize(),
            headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
        }).success(function (data) {
             alert("Thanks for Subscribing to our Newsletter!");
            $scope.subscription_email = "";
        });
    }

});